Skip to content

fix(core): reset creation mode when diffing into an existing projection - #8715

Merged
maiieul merged 3 commits into
QwikDev:build/v2from
maiieul:fix-duplicate-projected-children
Jun 11, 2026
Merged

maiieul merged 3 commits into
QwikDev:build/v2from
maiieul:fix-duplicate-projected-children

Conversation

@maiieul

@maiieul maiieul commented Jun 11, 2026 •

Copy link
Copy Markdown
Member

What is it?

  • Bug

Description

When a component throws a promise on first client render (e.g. a library resolving QRLs by throwing, like formisch's useResolvedQrl) and the promise resolution writes a signal the component already subscribed to, the component is diffed a second time before its child component has rendered its <Slot />. At that point the child host has no children yet, so descend() flips $isCreationMode$ on, and the sticky flag leaks into the existing projection from the first pass. expectElement then blindly re-creates plain element children instead of matching them (components survive because expectComponent matches by hash), and a trailing component sibling jumps the cursor past the stale element so expectNoMore never cleans it up — leaving duplicated DOM.

Symptom in an app: form fields rendered twice on every first SPA navigation to a route, correct again when revisiting (cached QRLs resolve synchronously, so nothing throws).

The fix: a projection never inherits creation mode from the surrounding level — an existing projection keeps its children across re-renders, so they must be diffed against, never re-created; it is in creation mode only when new or empty. Handled in descend() via an isProjection param (replacing shouldExpectNoChildren, which was already projection-only). Regression tests cover default and named slots; both fail without the behavior change.

Checklist

  • My code follows the developer guidelines of this project
  • I performed a self-review of my own code
  • I added a changeset with pnpm change
  • I added new tests to cover the fix / functionality

@maiieul
maiieul requested a review from a team as a code owner June 11, 2026 03:44
@changeset-bot

changeset-bot Bot commented Jun 11, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3014f12

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@qwik.dev/core Patch
eslint-plugin-qwik Patch
@qwik.dev/react Patch
@qwik.dev/router Patch
create-qwik Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@maiieul maiieul self-assigned this Jun 11, 2026
@maiieul maiieul moved this to Waiting For Review in Qwik Development Jun 11, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 11, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@qwik.dev/core

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/core@8715

@qwik.dev/router

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/router@8715

eslint-plugin-qwik

npm i https://pkg.pr.new/QwikDev/qwik/eslint-plugin-qwik@8715

create-qwik

npm i https://pkg.pr.new/QwikDev/qwik/create-qwik@8715

@qwik.dev/optimizer

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/optimizer@8715

commit: 3014f12

@github-actions

github-actions Bot commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor
built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
qwik-docs ✅ Ready (View Log) Visit Preview 3014f12

@Varixo Varixo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@maiieul
maiieul merged commit 9c4f0a9 into QwikDev:build/v2 Jun 11, 2026
47 checks passed
@github-project-automation github-project-automation Bot moved this from Waiting For Review to Done in Qwik Development Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants